{% extends 'layout.html' %}

{% block script %}
		<script>
			
			function loginResult(data){
				var errorCode = data.errorCode;				
				if(errorCode != 0){
					if(errorCode == 9001){
						toastr.warning('用户不存在','警告!');
					}else if(errorCode == 9002){
						toastr.warning('密码错误','警告!')
					}else if(errorCode == 9004){
						toastr.warning('暂无考试','警告!')
					}else{
						toastr.error('登录失败,请重试','错误!');						
					}
					return;
				}
				toastr.success('登录成功','成功!');
				window.localStorage['exatim'] = data['exatim'];
				var flg = data['flg'];
				var emeflg = data['emeflg'];
				var tpainr = data['tpainr'];
				var nexthtml = "";
				
				if('0' == flg){//初试
					if(emeflg == '0'){
						nexthtml = "examindex.html";						
					}else if(emeflg == '1'){
						nexthtml = "result.html";
					}else{						
						nexthtml = "exam.html?tpainr=" + tpainr;
					}					
				}else if('1' == flg){//复试
					if(emeflg == '0'){
						nexthtml = "advanceexam.html";						
					}else if(emeflg == '1'){
						nexthtml = "result.html";
					}else{
						nexthtml = "exam.html?tpainr=" + tpainr;
					}
				}
				//window.location.href = nexthtml;

				{% if error %}
					toastr.warning({{ msg }},'警告!');
				{% endif %}
			}
			
			$(function(){
				
				localStorage.clear();
				
				if(self != top){
					top.location.href = self.location.href;
				}
				
				$('#loginForm').on('submit',function(e){
					/*
					//e.preventDefault();
					var username = $('#uid').val();
					var password = $('#upwd').val();	
					if($.isEmptyObject(username) || $.isEmptyObject(password)){
						toastr.warning('请输入用户名密码','警告!');						
						return;
					}

					$.post("/login", { username: username, password: password },loginResult, "json");
					*/
				})	

				//$("#loginForm").validate();
			})
			
		</script>
{% endblock %}		
	
{% block body %}

		{% include 'flash.html' %}
	

		<div class="top">
			<div style="padding-top: 20px;padding-left: 30px;color: white;">
				<h2>Brilliance|新晨科技</h2>
				<p><strong>考试系统</strong></p>
			</div>			
		</div>
		<div class="middle">
			<img src="/static/img/lgnicn.png"/>
		</div>
		<div class="bottom container-fluid">
	        <form class="" role="form" id="loginForm" 
				action="/login" method="post" >
	            <div class="form-group">	            	
	                <input type="text" class="form-control"  id="uid" name="username" 
					  value="{{ request.form.username }}"	placeholder="请输入用户名" required>
	            </div>
	            <div class="form-group">	            	
	                <input type="password" class="form-control" id="upwd" name="password" placeholder="请输入密码" required>
	            </div>
	            <button type="submit" id="login_btn" class="btn btn-default" style="width: 100%;border-radius: 2em;background-color:  rgb(58,110,165);color: white;font-weight: bolder;height:2.7em;font-size: 1.3em;">登&nbsp;录</button>
	            <div class="text-left" style="font-size: large;margin: 20px auto;">&nbsp;&nbsp;没有帐号？点此 <a href="regis">注册</a> &nbsp; </div>
	        </form>
		</div>

{% endblock %}
	

